package ch.bfh.abcmmh.view.main.simulationparameterframe.subpanels.sliderlistener;

import javax.swing.JSlider;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;

import ch.bfh.abcmmh.controller.operating.vehiclepool.VehiclePool;
import ch.bfh.abcmmh.view.main.simulationparameterframe.subpanels.MayBeParameterPanel;

public class MayBeSliderListener implements ChangeListener{

	private VehiclePool vehiclePool;
	private MayBeParameterPanel mayBeParameterPanel;
	
	public MayBeSliderListener(MayBeParameterPanel mayBeParameterPanel, VehiclePool vehiclePool){
		this.vehiclePool = vehiclePool;
		this.mayBeParameterPanel = mayBeParameterPanel;
	}
	@Override
	public void stateChanged(ChangeEvent e) {
		JSlider source = (JSlider) e.getSource();
		
		float value = ((float)source.getValue())/10;
		if (source.equals(mayBeParameterPanel.getCarmbSlider())) {
			vehiclePool.updateCarMaybe(value);
		}else if (source.equals(mayBeParameterPanel.getBtmbSlider())) {
			vehiclePool.updateBTMaybe(value);
		}
	}

}
